<template name="zcheckbox">
	<view class="radio-view">
		<view class="uni-list theme-input" style="width:99%;">
            <checkbox-group @change="rc">
                <label class="uni-list-cell uni-list-cell-pd" v-for="item in choices" :key="item">
                    <view class="row-arrange">
                        <checkbox :value="item"  style="margin-top:10upx;" color="green"/>
						<text class="normal-font-size">{{item}}</text>
                    </view>
                    <view>{{item.name}}</view>
                </label>
            </checkbox-group>
        </view>
		<text class="tip" v-if="errorText.length>0">{{errorText}}</text>
	</view>
</template>

<script>
	export default {
		name : "zcheckbox",
		data() {
			return {
				value : [],
				errorText : ""
			};
		},
		props : {
			compType : {
				type : String,
				default : "zcheckbox"
			},
			choices : {
				type : Array,
				// value : true，
				default : true
			},
			minNum : {
				type : Number,
				default : 0
			},
			maxNum : {
				type : Number,
				default : -1
			},
			que : {
				type : String,
				default : "问题"
			}
		},
		methods: {
			
			get : function(){
				// alert("???")
				var num = this.value.length;
				// console.log(num)
				if(num < this.minNum){
					this.errorText = "没有选够数量";
					return null;
				}
				if(this.maxNum != -1 && num > this.maxNum){
					this.errorText = "选择数量过多";
					return null;
				}
				this.errorText = "";
				var res = []
				for(var i=0;i<this.value.length;i++){
					res.push(this.value[i]);
				}
				// console.log(this.value[0])
				// console.log(this.value[1])
				// console.log(this.value[2])
				return res;
			},
			rc : function(evt) {
				// console.log(evt.detail.value)
				this.value = evt.detail.value;
			}
		}
	}
</script>

<style>
	@import "../../../common/zcss.css";
	.radio-view{
		flex-direction: column;
	}
	.question{
		display: inline;
		font-size: 15upx;
	}
	/* #answer-view{
		flex-direction: row;
	} */
	.tip{
		padding-top: 5upx;
		margin-left: 5upx;
		color: red;
		font-size: 30upx;
	}
	
</style>
